package yannan.voiplock4ble.bean.ble;

import yannan.voiplock4ble.utils.ByteUtils;

/**
 * 说明：指静脉
 * 作者：mainTel
 * 时间：2016/12/6 10:41
 * 备注：
 */
public class VeinKey extends BaseBleResponse {

    /*
            //指静脉用户列表发送
        typedef struct {
            AppCommandHead_T head;
            uint8_t cmd;
            uint8_t reserve;	//对齐保留
            uint16_t token;
            uint8_t totalFinger;
            uint8_t packetUserNum;
            FingerUser_T fingerUser[];
        }FingerListSend_T;

        //指静脉用户结构体
        typedef struct{
            uint8_t phone[FINGER_ID_MAX_LENGTH+1];	//（指静脉手机号为11Byte 加1Byte冗余）
            BOOL fingerEnableFlag;		//指静脉用户使能标记
            uint8_t fingerUserType;
            uint8_t templateGroupId;
            uint8_t templateId;
            uint8_t reserve;	//对齐保留
            uint32_t timeStamp;
        }FingerUser_T;
        5A A5 20 00 00 00 06 00 45 A0
         04 00  0-1
         31 32 33 34 35 36 37 38 39 30 31   2-12
         00     13
         01 00    14 15 fingerEnableFlag
         00   16 fingerUserType
         00     17 templateGroupId
          03     18 templateId
         00     19 reserve
         AF 27 46 58    20-23 timeStamp
         FD 4A
     */

    public int fingerEnableFlag; //1启用 0未启用
    public int fingerUserType;   //0 管理员 1普通用户
    public int templateGroupId;  //templateGroupId, 假如是管理员 是 0      假如是普通用户 是 1
    public int templateId;
    public int reserve;
    public int timeStamp;
    public String phoneNum;

    public VeinKey(byte[] response) {
        super(response);
        if (content.length != 2) {
            byte[] phone = new byte[11];
            for (int i = 0; i < 11; i++) {
                phone[i] = content[i + 2];
            }
            phoneNum = new String(phone);
            fingerEnableFlag = content[14] & 0xff;
            fingerUserType = content[16] & 0xff;
            timeStamp = ByteUtils.byte2int(new byte[]{content[20], content[21], content[22], content[23]});
            templateGroupId = content[17]&0xff;
            templateId = content[18]&0xff;
        }
    }
}
